package com.freight.pay.utils;

import java.math.BigDecimal;

/**
 * Created by huyingtai
 * 2017-07-02 13:53
 */
public class MoneyUtil {

    /**
     * 元转分
     * @param yuan
     * @return
     */
    public static BigDecimal Yuan2Fen(Double yuan) {
        return BigDecimal.valueOf(yuan).movePointRight(2);
    }

    /**
     * 元转分
     * @param yuan
     * @return
     */
    public static BigDecimal Yuan2Fen(BigDecimal yuan) {
        return yuan.movePointRight(2);
    }


    /**
     * 分转元
     * @param fen
     * @return
     */
    public static BigDecimal Fen2Yuan(Integer fen) {
        return new BigDecimal(fen).movePointLeft(2);
    }

    /**
     * 分转元
     * @param fen
     * @return
     */
    public static BigDecimal Fen2Yuan(BigDecimal fen) {
        return   fen.movePointLeft(2);
    }

}
